<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    #main {
        width: 1600px;
        height: 700px;
    }
</style>

<body>
    <div id="main">
        .....
    </div>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/echarts/5.4.1/echarts.min.js"></script>
    <script>

        var chartDom = document.getElementById('main');
        var myChart = echarts.init(chartDom);
        var option;
        // prettier-ignore
        const hours = [
            '12a', '1a', '2a', '3a', '4a', '5a', '6a',
            '7a', '8a', '9a', '10a', '11a',
        ];
        // prettier-ignore
        const days = [
            'Saturday', 'Friday', 'Thursday',
            'Wednesday', 'Tuesday', 'Monday', 'Sunday'
        ];
        // prettier-ignore
        const data = [[0, 0, 5, 0.3], [0, 1, 1, 0.6], [0, 2, 6, 0.97], [0, 3, 8, 0.88],]
            .map(function (item) {
                return [item[1], item[0], item[2], item[3] || '-'];
            });
        console.log(data);
        option = {
            tooltip: {
                position: 'top'
            },
            grid: {
                height: '80%',
                top: '5%'
            },
            xAxis: {
                type: 'category',
                data: hours,
                splitArea: {
                    show: true
                },
                position: 'top'
            },
            yAxis: {
                type: 'category',
                data: days,
                splitArea: {
                    show: true
                }
            },
            visualMap: {
                min: 0,
                max: 10,
                calculable: true,
                orient: 'horizontal',
                left: 'center',
                bottom: '5%'
            },

            series: [
                {
                    name: 'Punch Card',
                    type: 'heatmap',
                    data: data,
                    label: {
                        show: true,
                        formatter: (p) => {
                            const v = p.data[2];
                            const pre = p.data[3];
                            console.log(p);
                            return `${v} \n\n ${pre * 100} % `
                            //  return `<span style='color: bllue'>${v}</span><br>3%`

                        },
                    },
                    emphasis: {
                        itemStyle: {
                            shadowBlur: 10,
                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                        }
                    }
                }
                // {
                //     name: "Punch Card",
                //     type: "heatmap",
                //     data: [[0, 0, data]],
                //     gridIndex: 3,
                //     xAxisIndex: 3,
                //     yAxisIndex: 3,
                //     label: {
                //         show: true,
                //         formatter: (p) => {
                //             // const v = p.value[2];
                //             // return `${v} | ${((v / total) * 100).toFixed(2)}%`;
                //             return '2'
                //         },
                //         color: "#333",
                //     },
                //     itemStyle: {
                //         borderWidth: 1,
                //         borderColor: "#009afe",
                //         color: "#E0EAFB",
                //     },
                // },
            ]
        };
        option && myChart.setOption(option);
    </script>
</body>

</html>